fix(llm): preserve OpenAI tool call extra content - #78
Conversation
|
head_sha: 变更摘要此 PR 主要为 OpenAI 兼容的工具调用增加对 主要改动
|
|
head_sha: 代码审查审查完成 — 汇总我已完成对全部 6 个变更文件的逐一审查。以下是审查结论: 审查覆盖确认
发现问题按严重度统计
整体风险评估此 PR 的变更范围紧凑且目标明确:在 唯一的可靠性隐患是
|
|
head_sha: The pipeline(pipeline number:2018) is running. Please wait a moment... |
|
已根据两份检视报告完成处理,更新提交: 已修改
未修改及理由
验证
|
c591021 to
dce9e0e
Compare
|
head_sha: Merge Verification Failed@xgg1227, this pr is not mergeable and the reasons are below: Not Enough Labels
Label Usage Tips
|
Paired: GitHub #78 ↔ GitCode !2018
fix(llm): preserve OpenAI-compatible tool call extra content
Problem
Some OpenAI-compatible providers attach protocol metadata to an individual
tool call under
tool_calls[].extra_content. Gemini 3 usesextra_content.google.thought_signatureand requires that signature to bereturned unchanged when the conversation continues after a function call.
The OpenAI SDK retains this field, but
OpenAIModelClientconverted each SDKtool call into agent-core's
ToolCallusing onlyid,type,name,arguments, andindex. The metadata was therefore discarded beforeBaseModelClientrebuilt the assistant message for the next request. A Gemini3 function-calling loop then failed on the continuation request with a 400
error for the missing thought signature.
Root cause and fix
This change treats
extra_contentas optional, opaque protocol metadata ratherthan adding Gemini-specific detection or manufacturing a signature:
extra_contentto the internalToolCallschema;model_extra;Standard OpenAI tool calls remain unchanged because no
extra_contentkey isemitted when the field is absent.
Reproduction
On an unmodified clean checkout of
upstream/develop, the new round-tripregression test fails because
extra_contentis absent after:AssistantMessage;With this change, the metadata survives the complete round trip.
Validation
pytest tests/unit_tests/core/foundation/llm -q: 301 passed, 3 skippedstreaming chunk merges, parallel tool calls, nested message conversion, and
standard tool calls without extension metadata.
gemini-3.1-flash-litethrough Google'sOpenAI-compatible endpoint: first request returned a tool call and signature;
the parsed and serialized metadata matched; the continuation request with the
tool result completed successfully.
ruff check,codespell, andgit diff --checkpass for the change; the newtest also passes isolated
mypychecking.Reference: https://ai.google.dev/gemini-api/docs/generate-content/thought-signatures